-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow deleting expired transactions from the API #2262
Conversation
67f25a9
to
1057537
Compare
fcefefb
to
d804856
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I can confirm it works fine on testnet. Some minor comments also.
@@ -2175,6 +2175,45 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do | |||
txDeleteFromDifferentWalletTest emptyWallet "wallets" | |||
txDeleteFromDifferentWalletTest emptyRandomWallet "byron-wallets" | |||
|
|||
it "TRANS_TTL_DELETE_01 - Shelley: can remove expired tx" $ \ctx -> do | |||
(wa, wb) <- (,) <$> fixtureWallet ctx <*> fixtureWallet ctx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wb could be an emptyWallet ctx
I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, fixed thanks.
-- yes, gone | ||
request @(ApiTransaction n) ctx linkDel Default Empty | ||
>>= expectResponseCode @IO HTTP.status404 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add tests forgetting expired transactions that:
- have metadata
- are transactions with withdrawals?
I'm guessing it doesn't matter but perhaps it's good to have such cases in regression suite, just in case.
(As far as I see, playing manually, there's no problem forgetting such expired transactions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confident that TTL is completely independent from these things.
apiError err404 NoSuchTransaction $ mconcat | ||
[ "I couldn't find a transaction with the given id: " | ||
, toText tid | ||
] | ||
ErrRemovePendingTxTransactionNoMorePending tid -> | ||
ErrRemoveTxAlreadyInLedger tid -> | ||
apiError err403 TransactionNotPending $ mconcat | ||
[ "The transaction with id: ", toText tid, | ||
" cannot be forgotten as it is not pending anymore." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the message could be now:
" cannot be forgotten as it is not pending anymore." | |
" cannot be forgotten as it is already in ledger." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.
2167: Add transaction TTL to payments API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Add transaction TTL to swagger spec. User provides the value in seconds. - [x] Add transaction TTL to API types - [x] Add TTL slot calculation to API handler function - [x] Adjust mkStdTx to make ttl easier - it now takes the expiry slot directly. - [x] Integration tests ### Comments Next PRs - [x] Allow deleting expired transactions ⇒ #2262 - [x] Add CLI option `cardano-wallet transaction create [--ttl=SECONDS]` ⇒ #2267 - [ ] Perhaps clean up the large number of function arguments and return values in transaction layer functions. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
2167: Add transaction TTL to payments API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Add transaction TTL to swagger spec. User provides the value in seconds. - [x] Add transaction TTL to API types - [x] Add TTL slot calculation to API handler function - [x] Adjust mkStdTx to make ttl easier - it now takes the expiry slot directly. - [x] Integration tests ### Comments Next PRs - [x] Allow deleting expired transactions ⇒ #2262 - [x] Add CLI option `cardano-wallet transaction create [--ttl=SECONDS]` ⇒ #2267 - [ ] Perhaps clean up the large number of function arguments and return values in transaction layer functions. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
2167: Add transaction TTL to payments API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Add transaction TTL to swagger spec. User provides the value in seconds. - [x] Add transaction TTL to API types - [x] Add TTL slot calculation to API handler function - [x] Adjust mkStdTx to make ttl easier - it now takes the expiry slot directly. - [x] Integration tests ### Comments Next PRs - [x] Allow deleting expired transactions ⇒ #2262 - [x] Add CLI option `cardano-wallet transaction create [--ttl=SECONDS]` ⇒ #2267 - [ ] Perhaps clean up the large number of function arguments and return values in transaction layer functions. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
apiError err404 NoSuchTransaction $ mconcat | ||
[ "I couldn't find a transaction with the given id: " | ||
, toText tid | ||
] | ||
ErrRemovePendingTxTransactionNoMorePending tid -> | ||
ErrRemoveTxAlreadyInLedger tid -> | ||
apiError err403 TransactionNotPending $ mconcat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also worth to change into TransactionNotInLedger
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yes fixed.
9580b98
to
737ffd3
Compare
bors r+ |
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. 2282: Increase bors timeout from 2h to 3h r=Anviking a=Anviking # Issue Number #2279 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] Increase bors timeout from 2h to 3h # Comments It seems hydra is often slow to schedule/run the jobs, causing ≈18% of bors r+ to fail. It should be better to increase the timeout to 3h, than to have it fail. This doesn't affect the timeout of buildkite or hydra themselves. <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io> Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Build failed (retrying...): |
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
I need to fix the integration tests. bors r- |
Canceled. |
866e53f
to
eb74e0e
Compare
bors r+ |
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Build failed: Is a proper failure due to new integration test TRANS_TTL_DELETE_01. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
data ErrRemoveTx | ||
= ErrRemoveTxNoSuchWallet ErrNoSuchWallet | ||
| ErrRemoveTxNoSuchTransaction (Hash "Tx") | ||
| ErrRemoveTxAlreadyInLedger (Hash "Tx") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
, removePendingTx = \pk tid -> ExceptT $ do | ||
alterDB errCannotRemovePendingTx db (mRemovePendingTx pk tid) | ||
, removePendingOrExpiredTx = \pk tid -> ExceptT $ do | ||
alterDB errCannotRemovePendingTx db (mRemovePendingOrExpiredTx pk tid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Just txMeta | txMeta ^. #status == InLedger -> | ||
( Left (CantRemoveTxInLedger wid tid), wal ) | ||
Just _ -> | ||
( Right (), wal { txHistory = Map.delete tid (txHistory wal) } ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
selectFirst ((TxMetaStatus ==. W.InLedger):filt) [] >>= \case | ||
Just _ -> pure 0 -- marked in ledger - refuse to delete | ||
Nothing -> fromIntegral <$> deleteWhereCount | ||
((TxMetaStatus <-. [W.Pending, W.Expired]):filt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
eb74e0e
to
f61495f
Compare
For the same reason as TRANS_TTL_03.
f61495f
to
d9da868
Compare
bors r+ |
Build succeeded: |
2267: Add CLI option for transaction TTL r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Hide shelley-specific CLI options in `cardano-wallet-jormungandr` (fixes #2169) - [x] Add option `cardano-wallet transaction create [--ttl=SECONDS]` - [ ] Update wiki page after merging. ### Comments - Based on PR #2262 branch - merge that first. 2297: Enable parallel integration tests in hydra r=Anviking a=Anviking # Issue Number ADP-466 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] Pass in `-j 8` - [x] Only run CLI tests in parallel if `CI` env var isn't set - [x] Clean up some debug printing in tests # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> 2302: Fix DB migration tests r=rvl a=piotr-iohk # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> # Overview - 098f6e5 Fix DB migration tests # Comments post release Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io> Co-authored-by: Johannes Lund <johannes.lund@iohk.io> Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
2267: Add CLI option for transaction TTL r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Hide shelley-specific CLI options in `cardano-wallet-jormungandr` (fixes #2169) - [x] Add option `cardano-wallet transaction create [--ttl=SECONDS]` - [ ] Update wiki page after merging. ### Comments - Based on PR #2262 branch - merge that first. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
2267: Add CLI option for transaction TTL r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Hide shelley-specific CLI options in `cardano-wallet-jormungandr` (fixes #2169) - [x] Add option `cardano-wallet transaction create [--ttl=SECONDS]` - [ ] Update wiki page after merging. ### Comments - Based on PR #2262 branch - merge that first. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io> Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
2267: Add CLI option for transaction TTL r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Hide shelley-specific CLI options in `cardano-wallet-jormungandr` (fixes #2169) - [x] Add option `cardano-wallet transaction create [--ttl=SECONDS]` - [ ] Update wiki page after merging. ### Comments - Based on PR #2262 branch - merge that first. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io> Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
2267: Add CLI option for transaction TTL r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Hide shelley-specific CLI options in `cardano-wallet-jormungandr` (fixes #2169) - [x] Add option `cardano-wallet transaction create [--ttl=SECONDS]` - [ ] Update wiki page after merging. ### Comments - Based on PR #2262 branch - merge that first. Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io> Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
Issue Number
ADP-93 / #1840
Overview
Comments